
clear all
import spss using "/Users/chuangchen/Library/CloudStorage/OneDrive-UniversityofPittsburgh/Pela project/PELA DATA/BASEDATOS_PERU_61.sav"



keep nestu Pais legis partido p28 p2901-p2907 p33 p35 p64 p65 p66 p66a p67 p68 p69 p70 p73

elabel variable (*) ("")

label variable nestu "Study number"
rename Pais pais
label variable pais "Country name"
label variable partido "Party name"
label variable legis "Legislature"

label drop labels0
label values pais
tostring pais, replace
replace pais="Peru"

replace legis=2011

* Party to be recoded
gen party = "."
replace party = "PG_ANR" if partido ==1 
replace party = "PG_PLRA" if partido ==2
replace party = "PG_UNACE" if partido ==3
replace party = "PG_Other" if partido ==4


drop partido 

rename party partido

label variable p64 "Ideology"
rename p64 ID1
replace ID1 = . if ID1 > 10
label variable p65 "Ideology of your party"
rename p65 ID2
replace ID2 = . if ID2 > 10

label variable p67 "Female (dummy 1 if woman)"
rename p67 female
recode female (1=0)(2=1)
label define female_label 1 "female" 0 "male"
label value female female_label

rename p66 religious
recode religious (2=0)
replace religious=. if religious > 2
label variable religious "Religious (dummy 1 if believer)"
label define religious_label 1 "believer" 0 "nonbeliever"
label value religious religious_label

gen rel_evangelical=1 if p66a==3
replace rel_evangelical=0 if rel_evangelical!=1 & rel_evangelical!=.
label variable rel_evangelical "Evangelical (dummy 1 if evangelical)"
label define rel_evan_lab 1 "Evangelical" 0 "Other"
label value rel_evangelical rel_evan_lab

gen rel_catholic=1 if p66a==1
replace rel_catholic=0 if rel_catholic!=1 & rel_catholic!=.
label variable rel_catholic "Catholic (dummy 1 if catholic)"
label define rel_cath_lab 1 "Catholic" 0 "Other"
label value rel_catholic rel_cath_lab

gen rel_other=1 if p66a != 1 & p66a != 3 & p66a < 6
replace rel_other=. if p66a > 5
replace rel_other=0 if rel_other!=1 & rel_other!=.
label variable rel_other "Religious Other (dummy 1 if other)"
label define rel_other_lab 1 "Other" 0 "Evangelical/Catholic"
label value rel_other rel_other_lab

drop p66a

* no question about church attendance
* rename p6bb religiosity

label variable p68 "Age (years)"
rename p68 age
replace age = . if age == 99

rename p73 education
label variable education "Highest level of education"
replace education = . if education > 6

rename p70 val_abortion
label variable val_abortion "Opinion about abortion"
replace val_abortion = . if val_abortion > 10

rename p69 val_divorce
label variable val_divorce "Opinion about divorce"
replace val_divorce = . if val_divorce > 10

rename p28 eco_regulated
label variable eco_regulated "Regulate Economy"
label drop labels32
replace eco_regulated = . if eco_regulated > 5
replace eco_regulated = eco_regulated*2
* attention to the rescaling

rename p33 eco_tax
replace eco_tax=. if eco_tax > 2
label variable eco_tax "Whether legislator prefers direct or indirect taxes"
label define tax_lab 1 "direct" 2 "indirect"
label value eco_tax tax_lab                                                             

rename p2901 eco_prices
label variable eco_prices "Price control"
replace eco_prices =. if eco_prices > 4

rename p2902 eco_education_p
label variable eco_education_p "Free primary education"
replace eco_education_p = . if eco_education_p > 4
* combines primary and secondary education

rename p2907 eco_education_u 
label variable eco_education_u "Free university education"
replace eco_education_u = . if eco_education_u > 7
recode eco_education_u (1=1) (2=3) (3=5) (4=7)


rename p2903 eco_housing
label variable eco_housing "Subsidize housing"
replace eco_housing =. if eco_housing > 4

rename p2904 eco_employment
label variable eco_employment "Employment creation"
replace eco_employment = . if eco_employment > 7
recode eco_employment (1=1) (2=3) (3=5) (4=7)


rename p2906 eco_health
label variable eco_health "Whether the state should provide health services"
recode eco_health (1=1) (2=3) (3=5) (4=7)
replace eco_health = . if eco_health > 7

rename p2905 eco_pensions
label variable eco_pensions "Pension"
replace eco_pensions = . if eco_pensions > 7
recode eco_pensions (1=1) (2=3) (3=5) (4=7)


rename p35 eco_natural
label variable eco_natural "Natural resources"
replace eco_natural = . if eco_natural > 5

gen wave = 2

save "Peru_wave2.dta", replace

